package com.woniu.day8.util;

import lombok.Data;
import lombok.NoArgsConstructor;
import static com.woniu.day8.util.FinalConst.*;



@Data
@NoArgsConstructor
public class ResultMessage<T> {
    private String message;
    private T data;
    private Integer code;
    public ResultMessage(String message, T data, Integer code) {
        this.message = message;
        this.data = data;
        this.code = code;
    }
    // 请求成功，支持多个 data 参数
    public static <T> ResultMessage<T> success(String message, Integer CODE, T data) {
        return new ResultMessage<>(message, data , CODE);
    }
    public static <T>ResultMessage<T> success(T data) {
        return new ResultMessage<>("success",data, SUCCESS);
    }
    // 请求失败，支持多个 data 参数
    public static <T> ResultMessage<T> fail(String message, Integer CODE, T data) {
        return new ResultMessage<>(message, data, CODE);
    }
    public static <T> ResultMessage<T> fail(T data) {

        return new ResultMessage<>("fail", data, INTERNAL_SERVER_ERROR);
    }

}
